<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增产品风格')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-post-add">
        <div class="form-group">
            <label class="col-sm-3 control-label ">产品风格名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="styleName" id="styleName" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">产品风格备注：</label>
            <div class="col-sm-8">
                <textarea id="styleRemark" name="styleRemark" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">显示顺序：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="styleSort" id="styleSort" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="remark" id="remark" required>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "pro/style";

    $("#form-post-add").validate({
        onkeyup: false,
        rules:{
            postName:{
                remote: {
                    url: prefix + "/checkStyleNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "styleName" : function() {
                            return $.common.trim($("#styleName").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },

            postSort:{
                digits:true
            },
        },
        messages: {
            "styleName": {
                remote: "产品风格名称已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-post-add').serialize());
        }
    }
</script>
</body>
</html>
